package com.party.core.dao.read.member;

import com.party.common.annotation.DataAuthParam;
import com.party.common.paging.Page;
import com.party.core.dao.read.BaseReadDao;
import com.party.core.model.member.MemberGroup;
import com.party.core.model.member.MemberGroupOutput;
import com.party.core.model.member.MemberWithPartner;
import com.party.core.model.member.PartnerInfoDetails;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @ClassName MemberGroupReadDao
 * @Description 机构用户
 * @Author yifeng
 * @Date 2019/9/10 17:48
 **/
@Repository
public interface MemberGroupReadDao extends BaseReadDao<MemberGroup> {
    /**
     * 获取子级id及自己
     *
     * @param partnerId 父级id
     * @return 子级id及自己
     * @author yifeng
     * @date 14:44 2019/9/12
     **/
    List<MemberGroup> getChildWithMy(String partnerId);

    /**
     * 获取子级id
     *
     * @param partnerId 父级id
     * @return 子级id
     * @author yifeng
     * @date 10:25 2019/9/18
     **/
    List<MemberGroup> getChild(String partnerId);

    /**
     * 子账号列表
     *
     * @param member
     * @param params
     * @param page
     * @return
     * @author yifeng
     * @date 10:06 2019/9/11
     **/
    List<MemberGroupOutput> childListPage(@Param(value = "member") MemberGroup member, @Param(value = "params") Map<String, Object> params, Page page);

    MemberGroup findByUserName(@Param("userName") String userName);

    List<String> findByMobileOrRealName(@Param(value = "mobile") String mobile, @Param(value = "name") String name,
                                        @Param(value = "type") Integer type);

    /**
     * 根据登录名查询会员信息
     *
     * @param loginName 登陆名称
     * @return 会员信息
     */
    MemberGroup findByLoginName(@Param("loginName") String loginName, @Param(value = "type") Integer type);

    MemberGroup findByMobile(@Param("mobile") String mobile, @Param(value = "type") Integer type);

    /**
     * @param value  username或者mobile
     * @param userId
     * @param key    username或者mobile
     * @return
     */
    List<MemberGroup> checkUserName(@Param("value") String value, @Param("key") String key,
                                    @Param("userId") String userId, @Param("type") Integer type);

    List<PartnerInfoDetails> getPartnerListData(MemberGroup member, Page page);

    List<MemberWithPartner> getAllPartnersSelectlist();

    /**
     * 合作商列表
     * @param member
     * @param params
     * @param page
     * @return
     */
    List<PartnerInfoDetails> partnerListPage(@Param("member") PartnerInfoDetails member, @Param("params") Map<String, Object> params, Page page);

    List<MemberGroup> webListPage(@Param(value = "member") MemberGroup member, @Param(value = "params") Map<String, Object> params, Page page);

    /**
     * @param loginName 登录名
     * @return 旧的用户
     * @Author yifeng
     * @Description 获取手机号对应的旧用户
     * @Date 10:04 2019/5/16
     **/
    MemberGroup findByLoginNameOld(@Param(value = "loginName") String loginName, @Param(value = "queryUserName") boolean queryUserName);

    List<MemberGroup> getPartnerList(MemberGroup member);

    List<MemberGroup> getAllChildWithMy(@Param("partnerId") String partnerId);

    List<MemberGroup> queryAdminBranchAndXZGSList(@Param("adminId") String adminId,@Param("partnerId") String partnerId);
}